/*
  * File:		pbd_error.h
  * Purpose:	PBD library error handler
  * Author:	yoyo
  * Date:	2011-6-24
  */

#ifndef _PBD_ERROR_H
#define _PBD_ERROR_H

#define PBD_LOG_LEVEL 1		// log level, select appropriate value
#define PBD_LOG_DEBUG 1
#define PBD_LOG_INFO 2
#define PBD_LOG_WARNING 3
#define PBD_LOG_ERR	4

#define PBD_FUN __FUNCTION__

/*
  * Libpbd information print function. Information print with 'level' less than
  * PBD_LOG_LEVEL[1] would not actually output.
  * @level - legal values are: PBD_LOG_DEBUG/PBD_LOG_INFO/PBD_LOG_WARNING/PBD_LOG_ERR
  * @fname -function name, always using PBD_FUN
  * @fmt, ... -information
  **/
void pbd_print(int level, const char *fname, const char *fmt, ...);

/*
  * Allocate 'size' memory, clear it and return
  * @size - memory size
  * Return the allocated memory, otherwise return NULL
  */
void *alloc_pbd_mem(int size);

/*
  * Free memory allcated for 'p'.
  */
void free_pbd_mem(void *p);

#endif

